#（1）
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
labels = np.array(['语文', '数学', '英语', '物理', '化学', '生物'])
x = np.arange(0, labels.size)
y_men = np.array([85.5, 91, 72, 59, 66, 55])
y_women = np.array([94, 82, 89.5, 62, 49, 53])
bar_width = 0.35
# 绘制柱形图
plt.bar(x - bar_width /2, y_men, width=bar_width, tick_label=labels)
plt.bar(x + bar_width /2, y_women, width=bar_width, tick_label=labels)
plt.show()
#（2）
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
labels = np.array(['语文', '数学', '英语', '物理', '化学', '生物'])
x = np.arange(0, labels.size)
y_men = np.array([85.5, 91, 72, 59, 66, 55])
y_women = np.array([94, 82, 89.5, 62, 49, 53])
bar_width = 0.5
# 绘制柱形图
plt.bar(x, y_men, width=bar_width, tick_label=labels)
plt.bar(x, y_women, bottom=y_men, width=bar_width, tick_label=labels)
plt.show()
